#encoding=utf-8
import logging

import requests

logger = logging.getLogger(__name__)

class RequestsUntil:

    ses = requests.session()
    def send_request(self,**kwargs):
        # 处理公共变量

        #把请求的四要素写入日志
        for key,value in kwargs.items():
            logger.info("请求: " + key + "参数: %s" % value)

        # 统一发送请求
        res = RequestsUntil.ses.request(**kwargs)
        #防止unicode编码错误
        if "json" in res.headers.get("Content-Type"):
            logger.info("响应数据: %s"% res.json())
        else:
            logger.info(res.text)
        return res